"use client"
import { Button, Checkbox, Form, Input } from 'antd';
import './types.css'
import type { FormProps } from 'antd';
import { LockOutlined, UserOutlined } from '@ant-design/icons';
type FieldType = {
  username?: string;
  password?: string;
  remember?: string;
};
// import { toLogins } from './request/http'
import { useRouter } from 'next/navigation';
import { http_login } from '../../utils/https';
export default function Home() {
  let router = useRouter()
  const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
    http_login(values).then(res=>{
      console.log(res);
      
      if(res.msg=="登录成功"){
        router.push("/fff")
        localStorage.setItem("token",res.data)
      }
      
    })
  };
      //   <Form.Item<FieldType>
      //     name="password"
      //     rules={[{ required: true, message: 'Please input your password!' }]}
      //   >
      //     <Input.Password />
      //   </Form.Item>

      //   <Form.Item<FieldType>
      //     name="password"
      //     rules={[{ required: true, message: 'Please input your password!' }]}
      //   >
      //     <Input.Password />
      //   </Form.Item>

      //   <Form.Item<FieldType> name="remember" valuePropName="checked" label={null}>
      //     <Checkbox>Remember me</Checkbox>
      //   </Form.Item>

      //   <Form.Item label={null}>
      //     <Button type="primary" htmlType="submit">
      //       Submit
      //     </Button>
      //   </Form.Item>
      // </Form>

  return (<div className="logintoadmin">
    <h2 style={{ marginTop: "40px" }}>客户关系管理系统</h2>
    <p>Customer Relationship Management</p>

    <Form
      name="basic"
      labelCol={{ span: 8 }}
      wrapperCol={{ span: 16 }}
      style={{ maxWidth: 600 }}
      onFinish={onFinish}
      autoComplete="off"
    >
      <Form.Item
        name="username"
        rules={[{ required: true, message: '用户名不能为空!' }]}
      >
        <Input prefix={<UserOutlined />} style={{ width: "450px", height: "50px", marginTop: "50px", margin: "10px 20px" }} />
      </Form.Item>
      <Form.Item
        name="password"
        style={{ marginBottom: "50px" }}
        rules={[{ required: true, message: '密码不能为空!' }]}
      >
        <Input.Password prefix={<LockOutlined />} style={{ width: "450px", height: "50px", marginTop: "50px", margin: "10px 20px" }} />
      </Form.Item>
      <p style={{ position: "absolute", left: "40px" }}>忘记密码？</p>
      <Form.Item label={null}>
        <Button style={{ width: "300px", height: "40px" }} type="primary" htmlType="submit">
          登录
        </Button>
      </Form.Item>
    </Form>
  </div>
  );
}

